#ifndef __SOFT_I2C_H__
#define __SOFT_I2C_H__

#define IMU_I2C_DBG

#ifdef IMU_I2C_DBG
#define I2C_PRINT    printf
#else
#define I2C_PRINT(...)
#endif

typedef enum __SOFT_I2C_CHAN_e__
{
    SOFT_I2C_CHAN_MAX,
} SOFT_I2C_CHAN_e;

typedef enum __SOFT_I2C_IO_CTRL_CMD_e__
{
    SOFT_I2C_IO_CTRL_CMD_INPUT,
    SOFT_I2C_IO_CTRL_CMD_OUTPUT,
    SOFT_I2C_IO_CTRL_CMD_READ,

    SOFT_I2C_IO_CTRL_CMD_MAX,
} SOFT_I2C_IO_CTRL_CMD_e;

typedef struct __SOFT_I2C_CFG_s__
{
    UINT32 iSdaPin;
    UINT32 iSclPin;
    UINT8 ucSlaveAddr;
    INT32 (*IoCtrl)(UINT32 pin, UINT32 cmd, UINT32 param);
    INT32 (*IoRead)(UINT32 pin, UINT32 *param);
} SOFT_I2C_CFG_s;

extern SOFT_I2C_CFG_s *pstSoftObj[];

//Data Define
#define SOFT_I2C_OP_READ                            (1)

#define SOFT_I2C_HOOK(Chan, pObj)                   \
do {\
    if (Chan >= SOFT_I2C_CHAN_MAX) \
    { \
        return STAT_ERR_INVAILD_PARAM; \
    } \
    pstSoftObj[Chan] = pObj; \
}while (0);

#define SOFT_PIN_LEVEL_HIGH                         1
#define SOFT_PIN_LEVEL_LOW                          0

extern ULONG soft_i2c_init(IN SOFT_I2C_CHAN_e cha);
extern ULONG soft_i2c_write(IN SOFT_I2C_CHAN_e chan, UCHAR regAddr, UCHAR *ptr, UINT32 len);
extern ULONG soft_i2c_read(IN SOFT_I2C_CHAN_e chan, UCHAR regAddr, UCHAR *ptr, UINT32 len);

#define SOFT_I2C_READ(Chan, regAddr, ptr, len)      \
    (Chan >= SOFT_I2C_CHAN_MAX) ? STAT_ERR_INVAILD_PARAM: \
    soft_i2c_read(Chan, regAddr, ptr, len);

#define SOFT_I2C_WRITE(Chan, regAddr, ptr, len )      \
    (Chan >= SOFT_I2C_CHAN_MAX) ? STAT_ERR_INVAILD_PARAM: \
    soft_i2c_write(Chan, regAddr, ptr, len);


#endif

